import cn.yunhe.entity.Bx;
import cn.yunhe.entity.PhoneBiz;
import cn.yunhe.entity.impl.BingXiang;
import cn.yunhe.entity.impl.PhoneBizImplProxy;
import cn.yunhe.excep.OutOfNumException;
import cn.yunhe.excep.OutOfStockException;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Demo1 {
    /*PhoneBiz phoneBiz = new PhoneBizImplProxy();*/
    ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");

    /*@Test
    public void test1() throws OutOfStockException {
        phoneBiz.buyPhone(10);
        phoneBiz.salePhone(8);
    }*/

    @Test
    public void test2() throws OutOfStockException {
        PhoneBiz phoneBiz = (PhoneBiz) ac.getBean("phoneBizImpl");
        phoneBiz.buyPhone(1000);
        phoneBiz.salePhone(666);
    }

    @Test
    public void test3() throws OutOfNumException {
        Bx bx = (Bx) ac.getBean("bingXiang");
        bx.saleBX(1);
    }

    @Test
    public void test4() {
        int a = 0;
        int b = 1;
        a = b++;
        System.out.println(a);
        a = ++b;
        System.out.println(a);
    }
}
